package com.tianyi.primeval.registry;

import com.tianyi.primeval.Primeval;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.ability.StunManager;
import mods.flammpfeil.slashblade.init.DefaultResources;
import mods.flammpfeil.slashblade.registry.combo.ComboState;
import mods.flammpfeil.slashblade.slasharts.Drive;
import mods.flammpfeil.slashblade.util.AttackManager;
import mods.flammpfeil.slashblade.slasharts.CircleSlash;
import mods.flammpfeil.slashblade.slasharts.JudgementCut;
import com.tianyi.primeval.specialattacks.*;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import java.awt.*;

import static com.tianyi.primeval.Primeval.MODID;

public class PLComboRegsitry {
    public static final DeferredRegister<ComboState> COMBO_STATES =
            DeferredRegister.create(ComboState.REGISTRY_KEY,MODID);

    public static final RegistryObject<ComboState> ALL_REUSE = COMBO_STATES.register//收刀动作，不写的话放完SA会闪退
            (
                    "all_reuse",
                    ComboState.Builder.newInstance().startAndEnd(459, 488).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation).next(entity -> SlashBlade.prefix("none"))
                            .nextOfTimeout(entity -> SlashBlade.prefix("none"))
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder().put(0, AttackManager::playQuickSheathSoundAction).build())
                            .releaseAction(ComboState::releaseActionQuickCharge)::build
            );
    public static final RegistryObject<ComboState> BIGDRIVE_VERTICAL = COMBO_STATES.register//注册名
            (
                    "big_drive",//名字
            ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                    .motionLoc(DefaultResources.ExMotionLocation)
                    .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                    .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                    .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                            .put(1, (entityIn) -> AttackManager.doSlash(entityIn, -80F, Vec3.ZERO, false, false, 1.5F))//调用
                            .put(3, (entityIn) -> Blowing.doSlash(entityIn, 90F, 20, Vec3.ZERO, false, 1, 1.1f))
                            .put(5, (entityIn) -> Blowing.doSlash(entityIn, 141F, 20, Vec3.ZERO, false, 1.2, 1.2f))
                            .put(7, (entityIn) -> Blowing.doSlash(entityIn, 192F, 20, Vec3.ZERO, false, 0.8, 1.3f))
                            .put(9, (entityIn) -> Blowing.doSlash(entityIn, 243F, 20, Vec3.ZERO, false, 0.8, 1.4f))
                            .put(11, (entityIn) -> Blowing.doSlash(entityIn, 294F, 20, Vec3.ZERO, false, 0.8, 1.5f))
                            .put(13, (entityIn) -> Blowing.doSlash(entityIn, 345F, 20, Vec3.ZERO, false, 1.4, 1.5f))
                            .put(15, (entityIn) -> Blowing.doSlash(entityIn, 36F, 20, Vec3.ZERO, false, 1.5, 1.5f))
                            .put(19, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 90))
                            .put(20, (entityIn) -> BigDriveSummon.doSlash(entityIn, 0F, 10, Vec3.ZERO, false, 185, 2f)).build())

                    .addHitEffect(StunManager::setStun)
                    ::build
    );
    public static final RegistryObject<ComboState> WIND_IS_VLOWING = COMBO_STATES.register
            (
                    "wind_is_blowing",
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, -0F, Vec3.ZERO, false, false, 1.2F))
                                    .put(4, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 180))
                                    .put(5, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 90))
                                    .put(6, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 0))
                                    .put(7, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, -90))
                                    .put(8, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,30.0,1F))
                                    .put(9, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,30.0,1F))




                                    .build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> XUE_YU = COMBO_STATES.register//注册名
            (
                    "xueyu",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 180F, Vec3.ZERO, false, false, 1.5F))
                                    .put(2, JudgementCut::doJudgementCut)
                                    .put(5, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,10.0,1F))
                                    .put(10, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,10.0,1F))
                                    .put(15, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,10.0,1F))
                                    .put(20, (entityIn) -> com.tianyi.primeval.specialattacks.Windpro.doSlash(entityIn,false,10.0,1F)).build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> HUANYING_GAI = COMBO_STATES.register//注册名
            (
                    "huanyinggai",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 90F, Vec3.ZERO, false, false, 1.5F))//调用
                                    .put(2, (entityIn) -> Drive.doSlash(entityIn, 90F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(3, (entityIn) -> AttackManager.doSlash(entityIn, 141F, Vec3.ZERO, false, false, 1.5F))
                                    .put(4, (entityIn) -> Drive.doSlash(entityIn, 141F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(5, (entityIn) -> AttackManager.doSlash(entityIn, 192F, Vec3.ZERO, false, false, 1.5F))
                                    .put(6, (entityIn) -> Drive.doSlash(entityIn, 192F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(7, (entityIn) -> AttackManager.doSlash(entityIn, 243F, Vec3.ZERO, false, false, 1.5F))
                                    .put(8, (entityIn) -> Drive.doSlash(entityIn, 243F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(9, (entityIn) -> AttackManager.doSlash(entityIn, 294F, Vec3.ZERO, false, false, 1.5F))
                                    .put(11, (entityIn) -> Drive.doSlash(entityIn, 294F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(12, (entityIn) -> AttackManager.doSlash(entityIn, 345F, Vec3.ZERO, false, false, 1.5F))
                                    .put(13, (entityIn) -> Drive.doSlash(entityIn, 345F, 20, Vec3.ZERO, false, 0.5, 2f))
                                    .put(14, (entityIn) -> AttackManager.doSlash(entityIn, 36F, Vec3.ZERO, false, false, 1.5F))
                                    .put(15, (entityIn) -> Drive.doSlash(entityIn, 36F, 20, Vec3.ZERO, false, 0.5, 2f)).build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> ERTIAN = COMBO_STATES.register//注册名
            (
                    "ertian",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(40, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 90F, Vec3.ZERO, false, false, 1.75))//调用
                                    .put(3, (entityIn) -> AttackManager.doSlash(entityIn, -115F, Vec3.ZERO, false, false, 1.75))
                                    .put(5, (entityIn) -> AttackManager.doSlash(entityIn, 141F, Vec3.ZERO, false, false, 1.75))
                                    .put(7, (entityIn) -> AttackManager.doSlash(entityIn, -166F, Vec3.ZERO, false, false, 1.75))
                                    .put(9, (entityIn) -> AttackManager.doSlash(entityIn, 192F, Vec3.ZERO, false, false, 1.75))
                                    .put(11, (entityIn) -> AttackManager.doSlash(entityIn, -217F, Vec3.ZERO, false, false, 1.75))
                                    .put(13, (entityIn) -> AttackManager.doSlash(entityIn, 243F, Vec3.ZERO, false, false, 1.75))
                                    .put(15, (entityIn) -> AttackManager.doSlash(entityIn, -263F, Vec3.ZERO, false, false, 1.75))
                                    .put(17, (entityIn) -> AttackManager.doSlash(entityIn, 294F, Vec3.ZERO, false, false, 1.75))
                                    .put(19, (entityIn) -> AttackManager.doSlash(entityIn, -319F, Vec3.ZERO, false, false, 1.75))
                                    .put(21, (entityIn) -> AttackManager.doSlash(entityIn, 345F, Vec3.ZERO, false, false, 1.75))
                                    .put(23, (entityIn) -> AttackManager.doSlash(entityIn, -10F, Vec3.ZERO, false, false, 1.75))
                                    .put(25, (entityIn) -> AttackManager.doSlash(entityIn, 36F, Vec3.ZERO, false, false, 1.75))
                                    .put(27, (entityIn) -> AttackManager.doSlash(entityIn, -61F, Vec3.ZERO, false, false, 1.75))
                                    .put(35, (entityIn) -> Drive.doSlash(entityIn, 0F, 20, Vec3.ZERO, false, 2, 2f)).build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> LIANZHAN = COMBO_STATES.register//注册名
            (
                    "lianzhan",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 90F, Vec3.ZERO, false, false, 2F))//调用
                                    .put(3, (entityIn) -> AttackManager.doSlash(entityIn, 141F, Vec3.ZERO, false, false, 2F))
                                    .put(5, (entityIn) -> AttackManager.doSlash(entityIn, 192F, Vec3.ZERO, false, false, 2F))
                                    .put(7, (entityIn) -> AttackManager.doSlash(entityIn, 243F, Vec3.ZERO, false, false, 2F))
                                    .put(9, (entityIn) -> AttackManager.doSlash(entityIn, 294F, Vec3.ZERO, false, false, 2F))
                                    .put(12, (entityIn) -> AttackManager.doSlash(entityIn, 345F, Vec3.ZERO, false, false, 2F))
                                    .put(14, (entityIn) -> AttackManager.doSlash(entityIn, 36F, Vec3.ZERO, false, false, 2F)).build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> LIANZHANB = COMBO_STATES.register//注册名
            (
                    "lianzhanb",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 90F, Vec3.ZERO, false, false, 0.75))
                                    .put(2, (entityIn) -> Drive.doSlash(entityIn, 90F, 20, Vec3.ZERO, false, 1, 2f))
                                    .put(3, (entityIn) -> AttackManager.doSlash(entityIn, 325F, Vec3.ZERO, false, false, 0.75))
                                    .put(4, (entityIn) -> Drive.doSlash(entityIn, 325F, 20, Vec3.ZERO, false, 1, 2f))
                                    .put(5, (entityIn) -> AttackManager.doSlash(entityIn, 235F, Vec3.ZERO, false, false, 0.75))
                                    .put(6, (entityIn) -> Drive.doSlash(entityIn, 235F, 20, Vec3.ZERO, false, 1, 2f)).build())

                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> SILIE = COMBO_STATES.register//注册名
            (
                    "silie",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 180F, Vec3.ZERO, false, false, 1.5F))
                                    .put(2, JudgementCut::doJudgementCut)
                                    .put(4, JudgementCut::doJudgementCut)
                                    .put(4, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,10.0,1F))
                                    .put(10, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,5.0,1F))
                                    .put(15, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,5.0,1F))
                                    .put(20, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,5.0,1F)).build())
                            .addHitEffect(StunManager::setStun)
                            ::build
            );
    public static final RegistryObject<ComboState> SILIEEX = COMBO_STATES.register//注册名
            (
                    "silieex",//名字
                    ComboState.Builder.newInstance().startAndEnd(1600, 1659).priority(50)
                            .motionLoc(DefaultResources.ExMotionLocation)
                            .next(ComboState.TimeoutNext.buildFromFrame(15, entity -> SlashBlade.prefix("none")))
                            .nextOfTimeout(entity -> Primeval.prefix("all_reuse"))//收刀或下一步动作
                            .addTickAction(ComboState.TimeLineTickAction.getBuilder()
                                    .put(1, (entityIn) -> AttackManager.doSlash(entityIn, 180F, Vec3.ZERO, false, false, 1.5F))
                                    .put(2, JudgementCut::doJudgementCut)
                                    .put(3, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 180))
                                    .put(4, JudgementCut::doJudgementCut)
                                    .put(5, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 90))
                                    .put(6, JudgementCut::doJudgementCut)
                                    .put(7, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, 0))
                                    .put(8, JudgementCut::doJudgementCut)
                                    .put(9, (entityIn) -> CircleSlash.doCircleSlashAttack(entityIn, -90))
                                    .put(12, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,10.0,3F))
                                    .put(14, (entityIn) -> com.tianyi.primeval.specialattacks.YingYu.doSlash(entityIn,false,15.0,3F)).build())
                            .addHitEffect(StunManager::setStun)
                            ::build
            );



}
